package com.yu.crm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.crm.domain.pojo.Gate;
import com.yu.crm.domain.pojo.Shift;
import com.yu.crm.domain.response.GateResponse;
import com.yu.crm.service.impl.GateService;
import com.yxzz.common.helper.valid.ValidatorHelpers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zds
 * @since 2021-03-12
 */
@Api(tags = "检票口口管理")
@RestController
@RequestMapping("/gate")
public class GateController {

    @Autowired
    private GateService gateService;

    @ApiOperation("根据id批量删除")
    @DeleteMapping("/remove-batch-by-id")
    public void removeBatchById(@RequestParam("ids") String ids){
        gateService.deleteByIds(ids);
    }

    @ApiOperation("根据id删除车站")
    @DeleteMapping("/remove-by-id/{id}")
    public void removeById(@PathVariable Long id){
        gateService.removeById(id);
    }

    @ApiOperation(value = "保存或修改")
    @PostMapping(value = "/saveOrUpdate")
    public void save(@RequestBody Gate gate){
        gateService.saveOrUpdate(gate);
    }

    /**
     * 通过检票口主键查询检票口详情
     * @param id 检票口主键
     * @return
     */
    @ApiOperation(value = "通过检票口主键查询检票口详情")
    @GetMapping(value = "/info-by-id")
    public Gate infoById(@RequestParam("id") Long id){
        ValidatorHelpers.notEmpty(id, "检票口编号不能为空");
        return gateService.infoById(id);
    }

    @ApiOperation(value = "查询列表")
    @GetMapping(value = "/page")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current",value = ""),
            @ApiImplicitParam(name = "size",value = "")
    })
    public IPage<GateResponse> getGateResponseList(@ApiIgnore Page<GateResponse> page,
                                                   @RequestParam(required = false) String stationName,
                                                   @RequestParam(required = false) String condition){
        return gateService.getGateResList(page, stationName, condition);
    }

//    @ApiOperation(value = "查询列表")
//    @GetMapping(value = "/page")
//    public IPage<Gate> getPage(Page<Gate> page, String condition) {
//        return gateService.getPage(page, condition);
//    }

}

